/**
 * GUI - Menu
 * @author Mikkel Christiansen, Søren Hansen
 */

package com.kea.firsthorse.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HTML;
import com.kea.firsthorse.shared.User;
import com.sksamuel.jqm4gwt.JQMContext;
import com.sksamuel.jqm4gwt.button.JQMButton;
import com.sksamuel.jqm4gwt.list.JQMList;
import com.sksamuel.jqm4gwt.list.JQMListItem;

public class GUI_Menu extends GUI_Master implements ClickHandler{

	private JQMList formattedlist;
	private JQMListItem sePolicer;
	private JQMListItem anmeldSkade;
	private JQMListItem faq;
	private JQMListItem indstillinger;
	private JQMButton btnLog;

	public GUI_Menu(User user) {
		super(false, true);
		
		HTML htmlwelcome = new HTML("Hej " + user.getFornavn()
				+ ".<br>Du var sidst logget ind " + user.getLastDate() + ".");
		add(htmlwelcome);

		formattedlist = new JQMList();
		formattedlist.addDivider("Generelt");
		formattedlist.setInset(true); // Afrunder hjørner og giver luft.
		add(formattedlist);

		GUI_SePolicer sepolicerpage = new GUI_SePolicer(user.getHorseList());
		sePolicer = formattedlist.addItem("Se policer", sepolicerpage);
		sePolicer
				.setThumbnail("images/sepolicer.png");
		
		GUI_AnmeldSkade anmeldSkadePage = new GUI_AnmeldSkade(user);
		anmeldSkade = formattedlist.addItem("Anmeld skade", anmeldSkadePage);
		anmeldSkade
				.setThumbnail("images/anmeldskade.png");

		formattedlist.addDivider("Andet");

		GUI_Faq faqpage = new GUI_Faq();
		faq = formattedlist.addItem("F.A.Q.", faqpage);
		faq.setThumbnail("images/faq.png");

		GUI_Settings settingspage = new GUI_Settings(user);
		indstillinger = formattedlist.addItem("Indstillinger", settingspage);
		indstillinger
				.setThumbnail("images/settings.png");
		
		btnLog = new JQMButton("Logout");
		btnLog.addClickHandler(this);
		add(btnLog);
	}

	@Override
	public void onClick(ClickEvent event) {
		//TODO Info om User skal slettes
		GUI_Login page = new GUI_Login();
		JQMContext.changePage(page);	
	}
}
